<?php
namespace Home\Controller;
class SendmsgController extends BaseController {
    public function index() {
        $this->signat = $this->signatures;
        $this->display();
    }
    
    public function postMsg() {
        $msgcontent = I('post.msgcontent')."【".I('post.sign')."】";
        $mobiles = I('post.mobiles');
        empty($msgcontent) || empty($mobiles) && $this->error('操作非法，请填写短信内容或接收短信的手机号',U('Sendmsg/index'));
        //发送短信
        $res = sendSMS($this->userinfo['msgname'], $this->userinfo['msgpass'], $mobiles, $msgcontent, $this->userinfo['msgapikey']);
        //进行记录
        $data['msgcontent'] = $msgcontent;
        $data['mobiles']    = $mobiles;
        $data['status']     = $res;
        $data['uid']        = $this->userinfo['id'];
        $data['logtime']    = time();
        D('Log')->addLog($data);
        $this->success('短信已经在路上',U('Sendmsg/index'));
    }
}

